import React from 'react';
import { inject, observer} from 'mobx-react';
import {WeaTableNew} from 'comsMobx';
import { Button } from 'antd';
import {WeaTop,WeaTab,WeaLeftRightLayout,WeaRightMenu,WeaPopoverHrm,WeaTools,WeaErrorPage,WeaLocaleProvider,WeaDialog} from 'ecCom';

import WorkflowFreeDesigner from '../../asyncComps/FreeNodeChart';
const WeaTable = WeaTableNew.WeaTable;
const getLabel = WeaLocaleProvider.getLabel;

@inject('wfFreeFlowTemplateStore')
@observer
class ModelSetFreeTemplate extends React.Component {
    constructor(props) {
		super(props);
    }
    doInit(props){
        const { wfFreeFlowTemplateStore } = props;
        const { searchList , getAddTemplateBaseData} = wfFreeFlowTemplateStore;
        
    }
    componentDidMount() {
        this.doInit(this.props);
    }
    componentWillReceiveProps(nextProps) {
    }
    render() {
        const { wfFreeFlowTemplateStore , location = {}} = this.props;
        const { setModelSetModalShow , modelSetModalShow , curTemplateId , curModelObject , searchList , modelSetCloseCb} = wfFreeFlowTemplateStore;
        const { query = {}} = location;
        const { workflowid = ''} = query;
        const dialogWidth = window.innerWidth * 0.9;
        const dialogHeight = window.innerHeight * 0.9;

        const designParams = {
            // workflowid :workflowid || '26064',
            isFree : '1',
            isReadOnlyModel : 'false',
            isFlowModel : '1',
            templateid : curTemplateId,
            modelSetModalShow,
            closeDialog : () => {setModelSetModalShow(false)},
            modelSetCloseCB : (callback)=>{
                wfFreeFlowTemplateStore.modelSetCloseCb = callback;
            },
            reLoadTemplateList : () => {searchList();}
        }
        return (
            <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@8a6a5v`}
                visible={modelSetModalShow}
                title={`${getLabel(16448,'模板设置')}-${curModelObject.name}`}
                icon="icon-coms-workflow"
                iconBgcolor='#0079DE'
                maskClosable={false}
                // onCancel={() => setModelSetModalShow(false)}
                onCancel={() => {modelSetCloseCb&&modelSetCloseCb()}}
                style={{width: dialogWidth,height:dialogHeight}}
                maxHeight={100000}
                hasScroll
            >
                <div className="wf-free-flowset-modelSet-Modal">
                    <WorkflowFreeDesigner ecId={`${this && this.props && this.props.ecId || ''}_WorkflowFreeDesigner@p4ao65`} {...designParams} openType='modeset'/>
                </div>
            </WeaDialog>
        )
    }
}

export default WeaTools.tryCatch(React, 
    props => <WeaErrorPage ecId={`${this && this.props && this.props.ecId || ''}_WeaErrorPage@c63z0u`} msg={ props.error ? props.error : getLabel(383324,' 对不起，该页面异常，请联系管理员 ')+'！'} />,
    {error: ""}
)(ModelSetFreeTemplate);